module Refinery
  module <%= namespacing %>
    class <%= class_name %> < Refinery::Core::BaseModel
<% if table_name == namespacing.underscore.pluralize -%>
      self.table_name = 'refinery_<%= plural_name %>'
<% end %>
<% if localized? -%>

      translates <%= localized_attributes.map { |a| ":#{a.name}" }.join(', ') %>
<% end -%>
<% if string_attributes.any? -%>

      validates <%= string_attributes.first.name.to_sym.inspect %>, :presence => true, :uniqueness => true
<% else -%>

      # def title was created automatically because you didn't specify a string field
      # when you ran the refinery:engine generator. <3 <3 Refinery CMS.
      def title
        "Override def title in vendor/extensions/<%= namespacing.underscore %>/app/models/refinery/<%= namespacing.underscore %>/<%= singular_name %>.rb"
      end
<% end -%>
<% image_attributes.each do |a| -%>

      belongs_to :<%= a.name -%>, :class_name => '::Refinery::Image'
<% end -%>
<% resource_attributes.each do |a| -%>

      belongs_to :<%= a.name %>, :class_name => '::Refinery::Resource'
<% end -%>

      # To enable admin searching, add acts_as_indexed on searchable fields, for example:
      #
      #   acts_as_indexed :fields => [:title]

    end
  end
end
